package com.qfmy.controller.common;

import com.qfmy.service.novel.FileService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 清风明月
 * @Package com.qfmy.controller.common
 * @date 2025/6/11
 * @description 文件操作
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/app/file")
public class FileController {

    /**
     * 注入service
     */
    @Resource
    private FileService fileService;

    /**
     * pdf转world文件
     */
    @RequestMapping("/pdfToWord")
    public ResponseEntity<byte[]> pdfToWord(@RequestParam MultipartFile file) {
        ResponseEntity<byte[]> word = fileService.pdfToWord(file);
        return word;
    }

    /**
     * pdf转txt文件
     */
    @RequestMapping("/pdfToTxt")
    public ResponseEntity<byte[]> pdfToTxt(@RequestParam MultipartFile file) {
        ResponseEntity<byte[]> txt = fileService.pdfToText(file);
        return txt;
    }

    /**
     * pdf转excel文件
     */
    @RequestMapping("/pdfToExcel")
    public ResponseEntity<byte[]> pdfToExcel(@RequestParam MultipartFile file) {
        ResponseEntity<byte[]> excel = fileService.pdfToExcel(file);
        return excel;
    }


}
